package cyan.gf.control;

import cyan.gf.data.Table;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.TableView;
import javafx.scene.control.TextInputControl;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by cyan on 2017/2/24.
 * Email:qsyan@vip.qq.com
 */
public class ControlUtils {

  public static boolean isInputBlank(TextInputControl... controls) {
    for (TextInputControl control : controls) {
      if (StringUtils.isBlank(control.getText())) {
        return false;
      }
    }
    return true;
  }

  public static ObservableList<Table> getSelectedItems(TableView<Table> tableView) {
    ObservableList<Table> tables = FXCollections.observableArrayList();
    tableView.getItems().forEach(o -> {
      if (o.getItemCheckBox().getValue().isSelected()) {
        tables.add(o);
      }
    });
    return tables;
  }
}
